typedef struct _IMAGE_ {
	HBITMAP hBitmap;
	PBYTE mem;
	int dx, dy;
	int line;
} *PIMAGE, IMAGE;

typedef struct {
	BYTE r, g, b;
	BYTE reserved;
} *PRGBENTRY, RGBENTRY;

#define IMAGE_LOADER_CREATEHANDLER		1
#define IMAGE_LOADER_OPENIMAGE			2
#define IMAGE_LOADER_LOADHEADER			3
#define IMAGE_LOADER_SCANLINE			4
#define IMAGE_LOADER_CLOSEIMAGE			5
#define IMAGE_LOADER_DELETEHANDLER		6

#define IMAGE_SAVER_CREATEHANDLER		1
#define IMAGE_SAVER_CREATEIMAGE			2
#define IMAGE_SAVER_SAVEHEADER			3
#define IMAGE_SAVER_WRITELINE			4
#define IMAGE_SAVER_CLOSEIMAGE			5
#define IMAGE_SAVER_DELETEHANDLER		6

typedef DWORD (*IMAGE_CALLBACK)(UINT, PVOID, PVOID);

typedef struct _IMAGEREADER_{
	char *extension;
	IMAGE_CALLBACK reader;
} *PIMAGEREADER, IMAGEREADER;

#define IMAGE_FLG_UPTODOWN		0x0001

typedef struct _IMAGEHEADER_{
	int bits;
	int dx, dy;
	int flg;
	int error;
} *PIMAGEHEADER, IMAGEHEADER;

void imageDelete(PIMAGE image);

PIMAGE imageCreate(int dx, int dy);

PIMAGE imageLoader(char *fileName, IMAGE_CALLBACK loader);

void imageSaver(PIMAGE image, char *fileName, IMAGE_CALLBACK saver);

// Readers
DWORD bmpReader(UINT command, PVOID handler, PVOID param);
DWORD pngReader(UINT command, PVOID handler, PVOID param);

// Writers
DWORD pngWrite(UINT command, PVOID handler, PVOID param);